<style>

    /*防篡改*/
    .anti-switch {
        margin-left: 20px;
        margin-top: 4px;
    }

    .anti_lib {
        margin-top: 15px;
    }

    .anti_lib_tit {
        margin-bottom: 15px;
        padding-bottom: 15px;
        border-bottom: #ddd 1px solid;
    }

    .anti_lib_con {
        background-color: #FBFBFB;
        border: #F0F0F0 1px solid;
        padding: 15px 10px;
    }

    .anti_rule_add {
        margin-bottom: 10px;
    }

        .anti_rule_add input {
            width: 395px;
        }

    .data-count-all {
        background-color: #FAFAFA;
        border: #ddd 1px solid;
        width: 100%;
        margin-bottom: 15px;
        float: left;
    }

        .data-count-all .data-count-box {
            height: 100%;
            text-align: center;
            width: 20%;
            float: left;
            margin-bottom: 15px;
        }

    .data-count-box .dname {
        color: #78797D;
        margin-top: 12px;
        margin-bottom: 10px;
    }

    .data-count-box .dval {
        color: #333;
    }

        .data-count-box .dval span {
            font-family: arial;
            color: #121313;
            font-size: 20px;
        }

    .anti_rule_list_type {
        float: left;
        width: 45%;
    }

    .anti_rule_list {
        width: 100%;
        float: left;
        margin-bottom: 20px;
    }

    .search-day {
        height: 32px;
        margin-left: 1px;
        margin-bottom: 15px;
    }

  .search-day span {
      float: left;
      height: 32px;
      line-height: 30px;
      border: #ddd 1px solid;
      padding: 0 20px;
      margin-left: -1px;
      cursor: pointer;
      position: relative;
    }

    .search-day span.cur {
      background-color: #20a53a;
      color: #fff;
    }

    .search-day span.cur input, .search-day span.cur em {
      color: #666;
    }

    .search-day span:last-child {
      padding: 0;
    }

    .search-day span input {
      border: 0 none;
      height: 30px;
      padding: 0 10px;
      width: 105px;
      background-image: url("");
      background-repeat: no-repeat;
      background-position: 86px center;
    }

    .search-day span input:active {
      border: 0 none;
    }

    .search-day span.cur input {
      color: #fff;
      background-color: #20a53a;
      background-image: url("");
    }

    .anti-open {
        position: absolute;
        top: 16px;
        left: 300px;
        line-height: 32px;
    }
	.bt-w-main{
      height:610px;
  	}
  	.nowrap_block{
		display: inline-block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
	}
</style>
<div class="bt-form">
    <div class="bt-w-main">
        <div class="bt-w-menu">
            <p class="bgw" onclick="anti_tamper.get_day()">概览</p>
            <p onclick="anti_tamper.operation_log()">操作日志</p>
        </div>
        <div class="bt-w-con pd15">
            <div class="anti-tamper-con"></div>
        </div>
    </div>
</div>
<script type="text/javascript">
	$('.layui-layer-page').css({ 'width': '900px'});
    $(".bt-w-menu p").click(function() {
        $(this).addClass('bgw').siblings().removeClass('bgw')
    });
	//表格头固定
	function tableFixed(name){
		var tableName = document.querySelector('#'+name);
		tableName.addEventListener('scroll',scrollHandle);
	}
	function scrollHandle (e){
		var scrollTop = this.scrollTop;
		//this.querySelector('thead').style.transform = 'translateY(' + scrollTop + 'px)';
		$(this).find("thead").css({"transform":"translateY("+scrollTop+"px)","position":"relative","z-index":"1"});
	}

    var anti_tamper = {
		get_day:function(){
			var con = '<div class="search-day"><span class="cur" onclick="anti_tamper.index(\''+anti_tamper.getBeforeDate(0)+'\')">今日</span><span onclick="anti_tamper.index(\''+anti_tamper.getBeforeDate(1)+'\')">昨日</span><span class="last-span"><input id="webdate-select" type="text" value=""></span></div><div class="total-all"></div><div class="webDataStats-day"></div>';
			$(".anti-tamper-con").html(con);
			anti_tamper.index();
			$(".search-day span").not(".last-span").click(function(){
				$(this).addClass("cur").siblings().removeClass("cur");
			})
			laydate.render({
				elem: '#webdate-select',
				value: new Date(),
				max: 0,
				done: function(value, date, endDate){
					anti_tamper.index(value);
					$("#date-select").val(value);
					$(".last-span").addClass("cur").siblings().removeClass("cur");
				}
			});
		},
		index: function(day){
			$(".webDataStats-day").html("<div class='cloading' style='margin-top:120px'>加载中，请稍后</div>");
			$.get('/plugin?action=a&s=get_index&name=tamper_proof',{day:day}, function (rdata) {
				if(rdata === false){
					layer.closeAll();
					layer.msg('当前插件未购买，请刷新列表后重试',{icon:2});
					return;
				}
                var serviceOpen = rdata.open ? 'checked' : ''
				var siteBody = '';
				var _day_total = 0;
				var _day_create = 0;
				var _day_delete = 0;
				var _day_modify = 0;
				var _day_move = 0;
                for (var i = 0; i < rdata.sites.length; i++) {
					var day_arr = rdata.sites[i].total;
                    var total = day_arr.site.total;
                    var dayTotal = day_arr.day.total;
					var _sitename = rdata.sites[i].siteName;
					// var _lock = rdata.sites[i].lock === "2" ? 1 : 0;
                    if (rdata.sites[i].lock == "2")
                    {
                        _lock = 1
                    }
                    else if (rdata.sites[i].lock == "1"){
                        _lock = 1
                    }
                    else if (rdata.sites[i].lock == "4"){
                        _lock = 1
                    }
                    else
                    {
                        _lock = 0
                    }
                    console.log(_lock)
                    $.each(day_arr.day, function (key, val) {
						switch(key){
							case 'total':
								_day_total += val;
								break;
							case 'create':
								_day_create += val;
								break;
							case 'delete':
								_day_delete += val;
								break;
							case 'modify':
								_day_modify += val;
								break;
							case 'move':
								_day_move += val;
								break;
						}
                    });

                    var statusOpt = '<div class="pull-left">\
                                        <input class="btswitch btswitch-ios" id="close_anti_site_'+i+'" type="checkbox" '+ (rdata.sites[i].bak_open ? 'checked' : '') + '>\
                                        <label class="btswitch-btn" for="close_anti_site_'+i+'" onclick=\'anti_tamper.set_site_status("'+_sitename+'",'+ (rdata.sites[i].bak_open?1:0) +','+ i +')\' style="width:2.0em;height:1.2em;margin-bottom:0"></label>\
                                    </div>'
                    var statusOpt1 = '<div class="pull-left">\
                                        <input class="btswitch btswitch-ios" id="close_anti_site1_'+i+'" type="checkbox" '+ (_lock ? 'checked' : '') + '>\
                                        <label class="btswitch-btn" for="close_anti_site1_'+i+'" onclick=\'anti_tamper.set_site_lock("'+_sitename+'","'+_lock+'",'+ i +')\' style="width:2.0em;height:1.2em;margin-bottom:0"></label>\
                                    </div>'
                    siteBody += '<tr>\
                                        <td><span class="nowrap_block" style="width:90px;" title="'+ _sitename + '">'+ _sitename + '</span></td>\
                                        <td><span class="nowrap_block" style="width:200px;" title="'+ _sitename + '">'+ rdata.sites[i].path + '</span></td>\
                                        <td><span title="创建：'+day_arr.site.create+'\n删除：'+day_arr.site.delete+'\n修改：'+day_arr.site.modify+'\n移动：'+day_arr.site.move+'">'+ total + '</span></td>\
                                        <td><span title="创建：'+day_arr.day.create+'\n删除：'+day_arr.day.delete+'\n修改：'+day_arr.day.modify+'\n移动：'+day_arr.day.move+'">'+ dayTotal + '</span></td>\
                                        <td>'+ statusOpt + '</td>\
                                        <td>'+ statusOpt1 + '</td>\
                                        <td>\
                                            <a onclick="anti_tamper.show_site_log(\''+ _sitename + '\')" class="btlink">日志</a> | \
                                            <a onclick="anti_tamper.site_exclude_path(\''+ _sitename + '\')" class="btlink">排除</a> | \
                                            <a onclick="anti_tamper.site_tmaper_ext(\''+ _sitename + '\')" class="btlink">保护</a>\
                                        </td >\
                                     </tr>'
                }
                var con = '<div class="anti-open">\
								<span class="pull-left">防篡改开关</span>\
								<div class="anti-switch pull-left">\
									<input class="btswitch btswitch-ios" id="close_anti" type="checkbox" '+ serviceOpen + '>\
									<label class="btswitch-btn" for="close_anti" onclick="anti_tamper.service_status()"></label>\
								</div>\
							</div>\
							<div class="anti_lib">\
								<div class="data-count-all">\
									<div class="data-count-box"><p class="dname">全部统计</p><p class="dval"><span>'+_day_total+'</span></p></div>\
									<div class="data-count-box"><p class="dname">创建次数</p><p class="dval"><span>'+_day_create+'</span></p></div>\
									<div class="data-count-box"><p class="dname">删除次数</p><p class="dval"><span>'+_day_delete+'</span></p></div>\
									<div class="data-count-box"><p class="dname">修改次数</p><p class="dval"><span>'+_day_modify+'</span></p></div>\
									<div class="data-count-box"><p class="dname">移动次数</p><p class="dval"><span>'+_day_move+'</span></p></div>\
								</div>\
							</div>';
				var con1 = '<div class="anti_rule_list">\
								<div class="divtable">\
								<div id="site_list_box" style="max-height:240px;overflow:auto;border:#ddd 1px solid">\
                                <table class="table table-hover" style="border:none">\
                                    <thead>\
                                        <tr><th>站点</th><th>监听目录</th><th>总次数</th><th>当日次数</th><th>备份状态</th><th>锁定状态(建议使用)</th><th width="120">操作</th></tr>\
                                    </thead>\
                                    <tbody>'+ siteBody + '</tbody>\
                                </table>\
								</div>\
                            </div></div>\
							<ul class="help-info-text c7">\
								<li>当【防篡改开关】状态为关闭时，则防篡改服务停止，所有站点将失去保护</li>\
								<li>当站点【备份状态】和【锁定状态】为关闭时，当前站点失去保护</li>\
								<li>使用 【备份模式】 将会消耗和源站点一样多的空间</li>\
								<li>使用 【锁定模式】 不会占用空间，推荐使用</li>\
								<li>我们为您默认配置了能有效防止常见篡改木马入侵的配置</li>\
								<li>您可以通过【排除】按钮来编辑不受保护的目录名称</li>\
								<li>您可以通过【保护】按钮来编辑受保护的文件类型</li>\
							</ul>';
                $(".total-all").html(con);
				$('.webDataStats-day').html(con1);
				tableFixed("site_list_box");
            })
		},
        //控制服务状态，若服务状态(open)为关闭，则所有站点失去防篡改保护
        // start 启动
        // stop 停止
        // restart 重启
        service_status: function () {
			var txt = "是否开启防篡改";
			var status = $("#close_anti").prop("checked");
			var _status = 'start';
			if(status){
				txt = "是否关闭放篡改";
				_status = "stop";
			}
			layer.confirm(txt,{title:"防篡改开关",icon:3,closeBtn:2,cancel:function(){
				if(status){
					$("#close_anti").prop("checked",true);
				}
				else{
					$("#close_anti").prop("checked",false);
				}
			}}, function() {
				var loadT = layer.msg('正在设置防篡改总开关状态，请稍后...',{icon:16,time:0});
				$.post('/plugin?action=a&s=service_admin&name=tamper_proof', { serviceStatus: _status }, function (rdata) {
					layer.close(loadT);
					layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 })
				});
			},function(){
				if(status){
					$("#close_anti").prop("checked",true);
				}
				else{
					$("#close_anti").prop("checked",false);
				}
			})
        },

        //站点状态控制
        //用于控制指定站点是否被保护,当open为False时，请求此接口将open改为True，反之为False
        // set_site_status: function (siteName) {
			// var loadT = layer.msg('正在处理，请稍候..',{icon:16,time:0});
        //     $.post('/plugin?action=a&s=set_site_status&name=tamper_proof', { siteName: siteName }, function (rdata) {
			// 	layer.close(loadT);
        //         layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 })
        //     });
        // },
        set_site_status: function (siteName,_lock,index) {
			var txt = "是否开启站点备份模式，该模式将会消耗与站点同等大小的磁盘空间！";
			var status = $("#close_anti_site_" + index).prop("checked");
			if(status){
				txt = "是否关闭站点备份模式";
			}
			layer.confirm(txt,{title:"防篡改开关",icon:3,closeBtn:2,cancel:function(){
				$("#close_anti_site_" + index).prop('checked',_lock === 1?true:false);
			}}, function() {
				var loadT = layer.msg('正在设置站点防篡改状态，请稍后...',{icon:16,time:0});
				$.post('/plugin?action=a&s=set_site_status&name=tamper_proof', { siteName: siteName }, function (rdata) {
					anti_tamper.get_day();
					layer.close(loadT);
					layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 })
				});
			},function(){
				
				$("#close_anti_site_" + index).prop('checked',_lock === 1?true:false);
			})
        },

        // set_site_lock: function (siteName, _lock) {
			// var loadT = layer.msg('正在处理，请稍候..',{icon:16,time:0});
			// _lock = _lock === "0" ? 1: 0
        //     console.log(_lock)
        //     $.post('/plugin?action=a&s=SetLockFile&name=tamper_proof', { siteName: siteName , lock: _lock}, function (rdata) {
			// 	layer.close(loadT);
        //         layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 })
        //     });
        // },
        set_site_lock: function (siteName, _lock,index) {
			var _lock = _lock === "0" ? 1: 0
			var status = $("#close_anti_site_" + index).prop("checked");
			if(status){
				txt = "是否开启站点锁定模式？";
			}else{
            	txt = "是否关闭站点锁定模式？"
			}
			layer.confirm(txt,{title:"防篡改开关",icon:3,closeBtn:2,cancel:function(){
				$("#close_anti_site1_"+index).prop('checked',!_lock?true:false);
			}}, function() {
				var loadT = layer.msg('正在设置站点锁定状态，请稍后...',{icon:16,time:0});
				$.post('/plugin?action=a&s=SetLockFile&name=tamper_proof', { siteName: siteName , lock: _lock}, function (rdata) {
					anti_tamper.get_day()
					layer.close(loadT);
					layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 })
				});
			},function(){
				$("#close_anti_site1_"+index).prop('checked',!_lock?true:false);
				// if(status){
				// 	$("#close_anti_site_1").prop("checked",true);
				// }
				// else{
				// 	$("#close_anti_site_1").prop("checked",false);
				// }
			})
        },

        //显示站点防御日志
        show_site_log: function (siteName, day) {
            if (day != undefined)  pdata['day'] = day
			var loadT = layer.msg('正在处理，请稍候..',{icon:16,time:0});
			$.post('/plugin?action=a&s=get_safe_logs&name=tamper_proof',{siteName: siteName,day:day}, function (rdata) {
				layer.close(loadT);
				var selectLogDay = "";
				var day = rdata[0];
				for(var i=0; i<rdata.days.length ;i++){
					selectLogDay += '<option value="'+rdata.days[i]+'">'+rdata.days[i]+'</option>';
				}
				if(rdata.logs == "") {
					layer.msg("暂无日志记录",{icon:6,shade:0.3,time:1000});
					return
				}
				var con = '';
				var logs_len = rdata.logs.length;
				for(var i=0; i<logs_len; i++){
					var txt = '';
					switch(rdata.logs[i][1]){
						case 'create':
							txt = '创建';
							break;
						case 'delete':
							txt = '删除';
							break;
						case 'modify':
							txt = '修改';
							break;
						case 'move':
							txt = '移动';
							break;
					}
					con += '<tr>\
					<td>'+anti_tamper.timestampToTime(rdata.logs[i][0])+'</td>\
					<td>'+txt+'</td>\
					<td>'+rdata.logs[i][2]+'</td>\
					<td>防护成功</td>\
					</tr>'
				}
				layer.open({
					type: 1,
					title: "日志【"+siteName+"】",
					area: ['860px','550px'],
					closeBtn: 2,
					shadeClose: false,
					content:'<div class="lib-box pd15 lib-box-log">\
							<div class="lib-con-title" style="height:40px">\
								<select id="selectLogDay" class="bt-input-text" onchange="anti_tamper.show_site_log_con(\''+siteName+'\',this.options[this.options.selectedIndex].value)">'+selectLogDay+'</select>\
								<button class="btn btn-success btn-sm va0 mb15 remove_logs mr5">清理日志</button>\
							</div>\
							<div class="lib-con">\
								<div class="divtable">\
									<div id="site_anti_log" style="max-height:400px;overflow:auto;border:#ddd 1px solid">\
									<table class="table table-hover" style="border:none;">\
										<thead><tr><th width="150">时间</th><th width="70">类型</th><th>文件</th><th width="80">状态</th></tr></thead>\
										<tbody id="LogDayCon"></tbody>\
									</table>\
									</div>\
									<p class="mtb10 c9" style="border: #ddd 1px solid;padding: 5px 8px;float: right;">共<span id="logs_len">'+logs_len+'</span>条记录</p>\
								</div>\
							</div>\
							</div>',
					success:function(){
						
						$('.remove_logs').click(function(){
							var select = $('#selectLogDay').val();
							var confirm = layer.confirm('是否清理&nbsp;['+ select  +']&nbsp;的日志？', {title:'提示',btn: ['确定','取消'],icon:0,closeBtn:2}, function(){
								var loadT = layer.msg('正在清理日志，请稍候..',{icon:16,time:0});
								$.post('/plugin?action=a&s=ClearDayLog&name=tamper_proof', {siteName: siteName,day:select}, function (rdata) {
									layer.close(loadT);
									layer.msg(rdata.msg,{icon:rdata.status ? 1 : 2})
									if(rdata.status){
										$('#LogDayCon').html('');
										$('#logs_len').html('0')
                                    }
								});
							});
						});
					}
				});
				anti_tamper.show_site_log_con(siteName,day);
				tableFixed("site_anti_log");
			});
        },
		show_site_log_con: function (siteName, day) {
			$("#site_waf_log").scrollTop(0);
			var loadT = layer.msg('正在获取，请稍候..',{icon:16,time:0});
			$.post('/plugin?action=a&s=get_safe_logs&name=tamper_proof', {siteName: siteName,day:day}, function (rdata) {
				layer.close(loadT);
				if(rdata.logs == "") {
					layer.msg("暂无日志记录",{icon:6,shade:0.3,time:1000});
					return
				}
				var con = '';
				var logs_len = rdata.logs.length;
				for(var i=0; i<logs_len; i++){
					var txt = '';
					switch(rdata.logs[i][1]){
						case 'create':
							txt = '创建';
							break;
						case 'delete':
							txt = '删除';
							break;
						case 'modify':
							txt = '修改';
							break;
						case 'move':
							txt = '移动';
							break;
					}
					con += '<tr>\
					<td>'+anti_tamper.timestampToTime(rdata.logs[i][0])+'</td>\
					<td>'+txt+'</td>\
					<td>'+rdata.logs[i][2]+'</td>\
					<td>防护成功</td>\
					</tr>'
				}
				$("#LogDayCon").html(con);
				$("#logs_len").text(logs_len);
			})
		},
        //获取排除的目录
        site_exclude_path: function (siteName) {
			var con = '<div class="pd15"><div class="anti_rule_add"><input class="bt-input-text mr5" type="rule"><button class="btn btn-default btn-sm va0" onclick=\'anti_tamper.add_exclude_path("'+siteName+'",this.previousSibling.value)\'>添加排除</button></div>\
                            <div class="anti_rule_list">\
								<div class="divtable">\
									<div id="site_exclude_path" style="max-height:360px;overflow:auto;border:#ddd 1px solid">\
									<table class="table table-hover" style="border:none">\
										<thead>\
											<tr><th>目录名称</th><th class="text-right">操作</th></tr>\
										</thead>\
										<tbody id="site_exclude_path_con">\
										</tbody>\
									</table>\
									</div>\
								</div>\
							</div>\
							<ul class="help-info-text c7">\
								<li>在此列表中的目录名将不受保护，针对与受保护的目录名互斥时作为补充配置</li>\
								<li>可以是目录名称,也可以是完整绝对路径,如: cache或/www/wwwroot/bt.cn/cache/</li>\
								<li>目录名称在完全匹配的情况下生效,绝对路径则使用从左到右匹配成功时生效</li>\
							</ul>\
							</div>';
			layer.open({
				type: 1,
				title: "排除目录【"+siteName+"】",
				area: ['500px','600px'],
				closeBtn: 2,
				shadeClose: false,
				content:con
			});
			anti_tamper.site_exclude_path_post(siteName);
			tableFixed("site_exclude_path");
        },
		site_exclude_path_post:function(siteName){
			var pdata = { siteName: siteName };
			$.post('/plugin?action=a&s=get_site_find&name=tamper_proof', pdata, function (rdata) {
				console.log(rdata);
                var excludeBody = ''
                for (var i=0; i < rdata.excludePath.length; i++) {
					excludeBody += '<tr><td>'+rdata.excludePath[i]+'</td><td class="text-right"><a href=\'javascript:anti_tamper.remove_exclude_path("'+siteName+'","'+rdata.excludePath[i]+'")\' class="btlink">删除</a></td></tr>';
				}
				$("#site_exclude_path_con").html(excludeBody);
            });
		},
        //显示受保护的文件类型
        site_tmaper_ext: function (siteName) {
			var con = '<div class="pd15"><div class="anti_rule_add"><input class="bt-input-text mr5" type="rule"><button class="btn btn-default btn-sm va0" onclick=\'anti_tamper.add_protect_ext("'+siteName+'",this.previousSibling.value)\'>添加保护</button></div>\
                            <div class="anti_rule_list">\
								<div class="divtable">\
									<div id="site_exclude_path" style="max-height:409px;overflow:auto;border:#ddd 1px solid">\
									<table class="table table-hover" style="border:none">\
										<thead>\
											<tr><th>扩展名</th><th class="text-right">操作</th></tr>\
										</thead>\
										<tbody id="site_exclude_path_con">\
										</tbody>\
									</table>\
									</div>\
								</div>\
							</div>\
							<ul class="help-info-text c7">\
								<li>在此列表中的文件类型为受保护的文件类型</li>\
								<li>一般添加常见容易被篡改的文件类型即可，如html,php,js等</li>\
							</ul>\
							</div>';
			layer.open({
				type: 1,
				title: "保护类型【"+siteName+"】",
				area: ['500px','600px'],
				closeBtn: 2,
				shadeClose: false,
				content:con
			});
			anti_tamper.site_tmaper_ext_post(siteName);
			tableFixed("site_exclude_path");
        },
		site_tmaper_ext_post:function(siteName){
			var pdata = { siteName: siteName };
			$.post('/plugin?action=a&s=get_site_find&name=tamper_proof', pdata, function (rdata) {
				console.log(rdata);
                var protectBody = ''
                for (var i=0; i < rdata.protectExt.length; i++) {
					protectBody += '<tr><td>'+rdata.protectExt[i]+'</td><td class="text-right"><a href=\'javascript:anti_tamper.remove_protect_ext("'+siteName+'","'+rdata.protectExt[i]+'")\' class="btlink">删除</a></td></tr>';
				}
				$("#site_exclude_path_con").html(protectBody);
            });
		},
        //添加排除目录
        add_exclude_path: function (siteName, path) {
            pdata = { siteName: siteName, excludePath: path }
            $.post('/plugin?action=a&s=add_excloud&name=tamper_proof', pdata, function (rdata) {
                layer.msg(rdata.msg, {icon:rdata.status?1:2});
				anti_tamper.site_exclude_path_post(siteName);
            });
        },
        //删除排除目录
        remove_exclude_path: function (siteName, path) {
            pdata = { siteName: siteName, excludePath: path }
            $.post('/plugin?action=a&s=remove_excloud&name=tamper_proof', pdata, function (rdata) {
                layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
				anti_tamper.site_exclude_path_post(siteName);
            });
        },
        //添加受保护的文件类型
        add_protect_ext: function (siteName, ext) {
            pdata = { siteName: siteName, protectExt: ext }
            $.post('/plugin?action=a&s=add_protect_ext&name=tamper_proof', pdata, function (rdata) {
                layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
				anti_tamper.site_tmaper_ext_post(siteName)
            });
        },
        //删除受保护的文件类型
        remove_protect_ext: function (siteName, ext) {
            pdata = { siteName: siteName, protectExt: ext }
            $.post('/plugin?action=a&s=remove_protect_ext&name=tamper_proof', pdata, function (rdata) {
                layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
				anti_tamper.site_tmaper_ext_post(siteName)
            });
        },
        //取操作日志
        operation_log: function (p) {
            if (p == undefined) p = 1;
            $.get('/plugin?action=a&s=get_logs&name=tamper_proof&tojs=anti_tamper.operation_log&p=' + p, function (rdata) {
                var logBody = '';
                for (var i = 0; i < rdata.data.length; i++) {
                    logBody += '<tr><td>'+rdata.data[i].addtime+'</td><td><span style="width: 605px;" class="nowrap_block" title="'+rdata.data[i].log+'">'+rdata.data[i].log+'</span></td></tr>'
                }

                var con = '<div class="anti_rule_list"><div class="divtable">\
                            <table class="table table-hover">\
                                <thead>\
                                    <tr><th>时间</th><th>详情</th></tr>\
                                </thead>\
                                <tbody>'+ logBody+'</tbody>\
                            </table>\
                        </div><div class="page" style="margin-top:15px">'+rdata.page+'</div</div>';
                $('.anti-tamper-con').html(con);
            });
        },
		//时间戳转换
		timestampToTime: function(date){
			var date = new Date(date*1000);
			var Y = date.getFullYear() + '-';
			var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
			var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
			var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
			var m = (date.getMinutes() <10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
			var s = (date.getSeconds() <10 ? '0' + date.getSeconds() : date.getSeconds());
			return Y+M+D+h+m+s;
		},
		//定义周期时间
		getBeforeDate: function(n){
			var n = n;
			var d = new Date();
			var year = d.getFullYear();
			var mon=d.getMonth()+1;
			var day=d.getDate();
			if(day <= n){
				if(mon>1) {
				   mon=mon-1;
				}
				else {
				 year = year-1;
				 mon = 12;
				}
			}
			d.setDate(d.getDate()-n);
			year = d.getFullYear();
			mon=d.getMonth()+1;
			day=d.getDate();
			s = year+"-"+(mon<10?('0'+mon):mon)+"-"+(day<10?('0'+day):day);
			return s;
		}
    }

    anti_tamper.get_day()
</script>
